package com.company.Sort;

import java.util.Arrays;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}14:23
 */
public class InsertSort2 {
    public static void main(String[] args) {
        int arr[] = {100,2,4,1,15};
        for (int i = 1; i < arr.length; i++){//移位法
            int indexValue = arr[i];
            int index = i - 1;
            while (index >= 0 && indexValue < arr[index]){
                arr[index + 1] = arr[index];
                index--;
            }
            arr[index+1] = indexValue;
            System.out.println("第"+i+"轮结果:");
            System.out.println(Arrays.toString(arr));
        }
    }
}
